package com.gjw.planeWar;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;

/**
 * @author Administrator
 * @since 2019/5/6.
 * 获取配置文件的工具类
 */
public class PropertyMgr {
    static Properties props = new Properties();

    static {
        try {
            props.load(PropertyMgr.class.getClassLoader().getResourceAsStream("config.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static Object get(String key) {
        if (props == null) {
            return null;
        }
        return props.get(key);
    }

    public static Integer getInt(String key) {
        if (props == null) {
            return null;
        }
        return Integer.valueOf(props.get(key).toString());
    }

    public static List<String> getStringList(String key) {
        if (props == null) {
            return null;
        }
        String[] strings = props.get(key).toString().split(",");
        return Arrays.asList(strings);
    }

    public static void main(String[] args) {
        System.out.println(PropertyMgr.get("initTankCount"));
    }
}
